import request from './request'

export const getCart = () => {
  const token = localStorage.getItem('token')
  if (token) {
    return request({
      url: '/api/cart',
      method: 'get'
    })
  } else {
    console.log('未登录，无法获取购物车商品')
  }
}

export const deleteShop = id => {
  return request({
    url: '/api/cart',
    method: 'DELETE',
    data: { id }
  })
}

export const putCart = (id, amount) => {
  return request({
    url: '/api/cart',
    method: 'PUT',
    data: { id: id, amount: amount }
  })
}
